<template>
  <div id="inner">
    <div class="inner-loading">
      <van-loading size="60px" type="spinner"></van-loading>
      <p>加载中...</p>
    </div>
  </div>
</template>

<script>
import { storage } from "../../plugins/storage";
import * as types from "../../store/mutation-types";
import config from "@/views/test/config";
import modelFunctions from "../../utils/modelFunction";
import { Dialog } from "vant";
export default {
  data() {
    return {
      urlParams: {},
      sign: "",
      signNo: ""
    };
  },
  created() {
    this.initData();
  },
  methods: {
    initData() {
      let param = modelFunctions.urlParam();
      if (param && param.back) {
        let params = JSON.parse(param.back);
        this.api
          .getOpenId({ appId: params.appId, bizNo: params.bizNo })
          .then(res => {
            if (res.data && res.data.openid) {
              this.getSSCTestSign(res.data);
            }
          });
      } else {
        Dialog.alert({
          title: "提示",
          message: "返回参数为空！"
        });
      }
    },
    getSSCTestSign(data) {
      // uri: data.sucRedirectUrl
      this.$store.dispatch("getSSCTestSign", {openId: data.openid, isIndep: "1", uri: data.sucRedirectUrl}).then(res => {

          this.sign = res.sign;
          this.signNo = res.signNo;
          this.pullCashier();
        });
    },
    pullCashier() {
      setTimeout(() => {
        location.href = `${config.sscServer}/indep/cashier?${this.sign}`;
      }, 1000);
    }
  }
};
</script>

<style lang="less">
#inner {
  width: 100%;
  height: 100%;
  position: relative;

  .inner-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}
</style>
